/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.expert.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.chlitina.store.common.config.Global;
import com.chlitina.store.common.persistence.Page;
import com.chlitina.store.common.web.BaseController;
import com.chlitina.store.modules.expert.entity.SolutionFaceAndCase;
import com.chlitina.store.modules.expert.service.SolutionFaceAndCaseService;
import com.chlitina.store.modules.expert.service.SolutionFaceService;

/**
 * 方案案例Controller
 * @author lvbo
 * @version 2013-06-11
 */
@Controller
@RequestMapping(value = Global.ADMIN_PATH+"/expert/solutionFaceAndCase")
public class SolutionFaceAndCaseController extends BaseController {

	@Autowired
	private SolutionFaceAndCaseService solutionFaceAndCaseService;
	@Autowired
	private SolutionFaceService solutionFaceService;
	
	@ModelAttribute
	public SolutionFaceAndCase get(@RequestParam(required=false) Long id) {
		if (id != null){
			return solutionFaceAndCaseService.get(id);
		}else{
			return new SolutionFaceAndCase();
		}
	}
	
	@RequestMapping(value = "listDetail")
	public String listDetail(Long solutionId, SolutionFaceAndCase solutionFaceAndCase, HttpServletRequest request, HttpServletResponse response, Model model) {
		if (solutionId != null) {
			Page<SolutionFaceAndCase> page = solutionFaceAndCaseService.find(new Page<SolutionFaceAndCase>(request, response), solutionFaceAndCase, solutionId); 
			model.addAttribute("solutionFace", solutionFaceService.get(solutionId));
			model.addAttribute("page", page);
		}
		return "modules/expert/solutionFaceAndCaseListDetail";
	}

	@RequestMapping(value = {"list", ""})
	public String list(Long solutionId, SolutionFaceAndCase solutionFaceAndCase, HttpServletRequest request, HttpServletResponse response, Model model) {
		if (solutionId != null) {
			Page<SolutionFaceAndCase> page = solutionFaceAndCaseService.find(new Page<SolutionFaceAndCase>(request, response), solutionFaceAndCase, solutionId); 
			model.addAttribute("solutionFaceId", solutionId);
			model.addAttribute("page", page);
		}
		return "modules/expert/solutionFaceAndCaseList";
	}

	@RequestMapping(value = "detail")
	public String detail(SolutionFaceAndCase solutionFaceAndCase, Model model) {
		model.addAttribute("solutionFaceAndCase", solutionFaceAndCase);
		return "modules/expert/solutionFaceAndCaseDetail";
	}
}
